<?php
class Integral_log_rankAction extends IntesysAction {
	function index(){
        $this->initView();
        $this->dao= D('Member');
		$integral_logDB=D('Integral_log');
        $map=$integral_logDB->filter();
		
        //获取筛选后的积分事件列表
		$join=['left join __INTEGRAL_LOG__ r on r.member_id=m.id','left join __MEMBER_GROUP__ g on g.id=m.group_id','left join __MEMBER_GROUP__ g2 on g2.id=g.pid','left join __INTEGRAL_RULE__ t on r.rule_id=t.id'];
		$field='m.name,sum(r.changenum) as totalnum,g2.title as groupname,m.id,m.img_url,m.id';
		$sort='totalnum desc';
		$this->dao->_listGroup($this->view,$join,$field,$map,$sort);
		
        //获取筛选后积分的总数
        $totalnum = $this->dao->alias('m')->join($join)->where($map)->sum('changenum');
        
	    //获取 筛选或添加 所需的积分类型，部门，所有员工等数据
        $this->assign('totalnum',$totalnum);
        $this->assign('grouplist',D('Member_group')->getGroup());
	    $this->assign('integraltypelist',D('Integral_type')->getType());
        $this->assign('post',$_POST);
	    $this->assign('ruletypelist',D('Integral_ruletype')->getRuletype());
	   
	    if($_POST['requestType']==10001011){
            die(json_encode(array('log'=>$list,'statu'=>1)));
        }else{
            $this->display();    
        }
	}
}

